Property-Grid Style Dialog

Description

To create a property-grid style Xdialog.

  1. Create a new Action Script.

  2. Select "Xdialog Windows" in the Category list.

  3. Select "Display an XDialog Box" in the Action list.

  4. Click OK to display the Script Genie.

  5. Enter the name of new variable in the Variable Name field.

  6. Optionally, change the value of the Prompt field.

  7. Optionally, change the selection in the data Type list.

  8. Set the Width and Height of the resulting dialog box.

  9. Select "Property-grid style Dialog" in the Style list.

  10. Click Define Property-Grid Dialog to display the Property Grid Builder.

    images/AS_Property_Grid_Style_Xdialog.gif

Property Grid Builder

The Items tab of the Property Grid Builder allows you to specify a hierarchy of menu entries.

  • Category entries - are menu groupings. Categories can be collapsed and expanded.

  • Item entries - are menu selections. Items set the value of variables and generate events.

For each entry click Add to display the Add Entry dialog.

  1. Select one of the following Type radio buttons:

    • ((|#New_Category|New Category))

    • ((|#Item|Item))

  2. Enter the text for the entry in the Settings > Name field.

Item

If you selected "Item" in step 1a, enter values into the following fields.

  1. Enter the name of the variable that will be set in the Variable name field.

  2. Select the Variable scope. The options are:

    • "Local"

    • "Session"

    • "Global"

  3. Select the Variable type. The options are:

    • "Character"

    • "Numeric"

    • "Logical"

  4. Optionally, set a Default Value for the variable. Character strings should not be quoted.

  5. Select the Control type. The options are:

    • "Edit" - allows you to enter a character, date, or numeric value

    • "Smart" - opens a dialog that helps you select or enter a value

    • "Combo" - presents a list, but does not allow new entries

    • "EditCombo" - presents a list, but allows new entries

    • "Checkbox" - for logical variables

  6. Input the Event name of the variable.

  7. Click OK to return to the Property Sheet Builder.

  8. Optionally, change the value the Base Settings > Level property This sets the indent level of the control. You may also use the and buttons to adjust the indent level of an item.

  9. Optionally, enter values the Control Properties > Data field.

    • 1. For Combo controls enter a comma separated list or an "@" followed by the name of variable containing a CR-LF delimited list. You must DIM this variable and populate this list on the Initial Code tab. See Defining the Contents of a Combo Box.

    • 2. For Smart Button controls, enter the code to execute in the format: field_name = function(). See Creating Smart Fields.

    • 3. For Check box controls (for logical variables), enter the check box text. Character values should not be quoted.

  10. Set the value of Control Properties > Enable. The options are:

    • .T. = always enable the item

    • .F. = always disable the item

    • A logical variable or expression that can be changed from TRUE to FALSE to selectively enable or disable the item.

  11. Set the value of Control Properties > Show. The options are:

    • .T. = display the item

    • .F. = hide the item

    • A logical variable or expression that can be changed from TRUE to FALSE to selectively display or hide the item.

  12. Set the value of Control Properties > Label Italic. The options are:

    • .T. = show the label with an italic font

    • .F. = show the label with a normal font

    • A logical variable or expression that can be changed from TRUE to FALSE to selectively change the label from normal to italic.

  13. Set the value of Control Properties > Input Error. A logical variable or expression that can be changed from TRUE to FALSE to selectively change the input text from black (no error) to red (error).

  14. Set the value of Control Properties > Input Italic. The options are:

    • .T. = show the input text with an italic font

    • .F. = show the input text with a normal font

    • A logical variable or expression that can be changed from TRUE to FALSE to selectively change the input text from normal to italic.

  15. Set the value of Control Properties > Input Bold. The options are:

    • .T. = show the input text with a bold font

    • .F. = show the input text with a normal font

    • A logical variable or expression that can be changed from TRUE to FALSE to selectively change the input text from normal to bold.

  16. Set the value of Control Properties > Help. This is the text that appears in the window at the bottom of the builder when you place the cursor into a field.

New Category

If you selected "New Category" in step 1a:

  1. Enter the text to display in the Settings Name control.

  2. Click OK to return to the Property Grid Builder.

  3. Optionally, change the value of the Base Settings > Level property. This sets the indent level of the control. You may also use the and buttons to adjust the indent level of a category.

  4. Optionally, change the value of the Base Settings > Initial state property. The options are:

    • Opened

    • Closed

  5. Set the value of Control Properties > Show Category. The options are:

    • .T. = display the category

    • .F. = hide the category

    • A logical variable or expression that can be changed from TRUE to FALSE to selectively display or hide the category.

  6. Set the value of Control Properties > Show Label. The options are:

    • .T. = display the category label

    • .F. = hide the category label

    • A logical variable or expression that can be changed from TRUE to FALSE to selectively display or hide the category label.

Other Tabs

  1. Use the Initial Code tab to other DIM variable and set the initial values of variables, such as those containing lists.

  2. Use the Event Code tab to respond to item events with Xbasic code to enable or disable objects, hide or show objects, and to run scripts.

  3. Use the Verbs tab to define buttons that look like hyperlinks.

  4. Use the Propgrid Settings tab to define the style and appearance of the control.

Verbs Tab

Verbs and their associated events allow you to add hyperlink styled buttons to the property grid. These buttons can execute any Xbasic code. Verbs are entirely optional. For each button you wish to add:

  1. Display the Verbs tab.

  2. Click Add Verb to display the Add Verb dialog. This step creates the button. Enter a value and click OK.

  3. Switch to the Event Code tab and create a new event that will respond to the Keypress event of the new button.

  4. Add the code that the event will run.

    images/AS_Property_Grid_Verb_Event.gif
  5. Display the Verbs tab again.

  6. Select the button's event from the Event list.

Propgrid Settings Tab

  1. Optionally, select a style from the Theme list. This picture shows 2 of the 7 possible styles.

    images/AS_Property_Grid_Styles.gif
  2. Optionally, change the Order property of the grid. This setting defines how entries will be displayed. The options are:

    • "NoSort"

    • "Category"

    • "Alphabetic"

  3. Optionally, check Set splitter width. When selected, you may enter a fractional number between 0 and 1 into the control. This defines the percentage of the total width that will be allotted to the left (label) column, as opposed to the right (text) column.

  4. Optionally, clear Has Help to disable the display of Help.

  5. Optionally, clear Has Toolbar to disable the display of the Toolbar.

    images/AS_Property_Grid_Toolbar_Help.gif
  6. Enter a name under which to save the settings of the dialog box in the registry in the Remember Name field. This allows the dialog to resume its previous state when your application restarts.

  7. Click OK to exit the Property Grid Builder.

  8. Continue with Define Title of Display an Xdialog Box.

Defining the Contents of a Combo Box

There are two ways to populate a combo box.

  1. Enter the values into the Control Properties > Data field in the format: Value1,Value2,Value3...ValueN.

  2. Define the list with Xbasic code:

    • 1. Place a reference to the list in the Control Properties > Data field in the format: @ListVariableName.

    • 2. Display the Initial Code tab.

    • 3. Set the values of the list in the following format:

      ListVariableName = <<%str%
      Value1
      Value2
      Value3
      ...
      ValueN
      %str%

Creating Smart Fields

Smart fields are highly desirable when you want to enter the following types of data.

To return multiple selections, try something like this. This function call uses UI_GET_LIST2() to return one or more values from a list created by TABLE.EXTERNAL_FIELD_NAME_GET().

myFields = ui_get_list2("Select Fields", "", table.external_field_name_get(tbl_name, "N"), 2)

Hiding and Displaying an Item or Category

  1. Create a logical variable with an initial value that corresponds to whether the item or category should be initially hidden or displayed.

    dim showVariableName as L = .F.
  2. Place the name of this variable into the Control Properties > Show field.

  3. Display the Event Code tab of the Property Grid Builder.

  4. Select the Change event of the item that will trigger the change from hidden or shown.

  5. Enter code that resets the value of showVariableName. See the following pictures for an example.

The Item Properties > Variable Name field of the "Database" item contains the variable cDatabase. The user selection in the combo box sets this variable's value.

images/AS_Property_Grid_Setup_Hide_Show.gif

The event variable eDatabase has code attached to its Change event. The code tests for the value of the cDatabase variable, and sets the value of showADOProducts.

images/AS_Property_Grid_Builder_Event_Tab.gif

The Control Properties > Show field of the "ADO Products" item contains the showADOProducts variable. When the value is TRUE (.T.), the item is visible. When the value is FALSE (.F.), the item is hidden.

images/AS_Property_Grid_Builder_Hide_Show.gif

This picture shows the property sheet dialog with the "ODBC Products" item that appears only when "ODBC Compatible (AlphaDAO)" is selected from the "Database" list.

images/AS_Property_Grid_Hidden_and_Displayed_Item.gif

Responding to Events

Each category and item generates the following events:

  • Change

  • SetFocus

  • KillFocus

  • Keypress

  • Keydown

  • Keyup

You can attach Xbasic code to any of these events.

See Also